﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ComponentModel;
using System.Text;
using Global.Class.Library;


namespace DataTransferObject.MetaDataList
{
    public class ListItemCommodityMaster : NotifyPropertyChangeObject
    {
        private int commodityID;

        private DateTime entryDate;

        private string description;
        private string descriptionOfficial;
        private string descriptionOriginal;
        private string codeFactory;
        private string codeTechnical;
        private string unit;
        private string packing;
        private string origin;
        private string hsCode;
        private string other;

        private int previousCommodityID;
        private int itemCategoryID;
        private int itemBrandID;
        private int itemTypeID;
        private int supplierID;
        private int noExpiryDate;
        private int itemGroupID;
        private int itemClassID;
        private int itemPM_APMID;

        private double weight;
        private double leadTime;
        private double quantityAlert;
        private double quantityReorder;
        private double customsPercent;
        private double excisePercent;
        private double vatPercent;

        private bool inActive;
        private bool isNoExpiryDate;
        private bool isCustomsPercent;
        private bool isExcisePercent;
        private bool isVATPercent;
        private bool isOrder;
        private bool isPromotion;
        private bool isSample;
        private bool isMerchandising;



        public ListItemCommodityMaster()
        {
            GlobalDefaultValue.Apply(this);
            this.EntryDate = DateTime.Now;
        }

        #region Properties


        [DefaultValue(-1)]
        public int CommodityID
        {
            get { return this.commodityID; }
            set { ApplyPropertyChange<ListItemCommodityMaster, int>(ref this.commodityID, o => o.CommodityID, value); }
        }


        [DefaultValue(typeof(DateTime), "01/01/1900")]
        public DateTime EntryDate
        {
            get { return this.entryDate; }
            set { ApplyPropertyChange<ListItemCommodityMaster, DateTime>(ref this.entryDate, o => o.EntryDate, value); }
        }


        [DefaultValue("******")]
        public string Description
        {
            get { return this.description; }
            set { ApplyPropertyChange<ListItemCommodityMaster, string>(ref this.description, o => o.Description, value); }
        }

        [DefaultValue("")]
        public string DescriptionOfficial
        {
            get { return this.descriptionOfficial; }
            set { ApplyPropertyChange<ListItemCommodityMaster, string>(ref this.descriptionOfficial, o => o.DescriptionOfficial, value); }
        }

        [DefaultValue("")]
        public string DescriptionOriginal
        {
            get { return this.descriptionOriginal; }
            set { ApplyPropertyChange<ListItemCommodityMaster, string>(ref this.descriptionOriginal, o => o.DescriptionOriginal, value); }
        }

        [DefaultValue("")]
        public string CodeFactory
        {
            get { return this.codeFactory; }
            set { ApplyPropertyChange<ListItemCommodityMaster, string>(ref this.codeFactory, o => o.CodeFactory, value); }
        }

        [DefaultValue("")]
        public string CodeTechnical
        {
            get { return this.codeTechnical; }
            set { ApplyPropertyChange<ListItemCommodityMaster, string>(ref this.codeTechnical, o => o.CodeTechnical, value); }
        }

        //[DefaultValue("")]
        public string Unit
        {
            get { return this.unit; }
            set { ApplyPropertyChange<ListItemCommodityMaster, string>(ref this.unit, o => o.Unit, value); }
        }

        //[DefaultValue("")]
        public string Packing
        {
            get { return this.packing; }
            set { ApplyPropertyChange<ListItemCommodityMaster, string>(ref this.packing, o => o.Packing, value); }
        }

        //[DefaultValue("")]
        public string Origin
        {
            get { return this.origin; }
            set { ApplyPropertyChange<ListItemCommodityMaster, string>(ref this.origin, o => o.Origin, value); }
        }

        //[DefaultValue("")]
        public string HSCode
        {
            get { return this.hsCode; }
            set { ApplyPropertyChange<ListItemCommodityMaster, string>(ref this.hsCode, o => o.HSCode, value); }
        }

        [DefaultValue("")]
        public string Other
        {
            get { return this.other; }
            set { ApplyPropertyChange<ListItemCommodityMaster, string>(ref this.other, o => o.Other, value); }
        }

        [DefaultValue(0)]
        public int PreviousCommodityID
        {
            get { return this.previousCommodityID; }
            set { ApplyPropertyChange<ListItemCommodityMaster, int>(ref this.previousCommodityID, o => o.PreviousCommodityID, value); }
        }

        //[DefaultValue(0)]
        public int ItemCategoryID
        {
            get { return this.itemCategoryID; }
            set { ApplyPropertyChange<ListItemCommodityMaster, int>(ref this.itemCategoryID, o => o.ItemCategoryID, value); }
        }

        //[DefaultValue(0)]
        public int ItemBrandID
        {
            get { return this.itemBrandID; }
            set { ApplyPropertyChange<ListItemCommodityMaster, int>(ref this.itemBrandID, o => o.ItemBrandID, value); }
        }

        //[DefaultValue(0)]
        public int ItemTypeID
        {
            get { return this.itemTypeID; }
            set { ApplyPropertyChange<ListItemCommodityMaster, int>(ref this.itemTypeID, o => o.ItemTypeID, value); }
        }

        //[DefaultValue(0)]
        public int SupplierID
        {
            get { return this.supplierID; }
            set { ApplyPropertyChange<ListItemCommodityMaster, int>(ref this.supplierID, o => o.SupplierID, value); }
        }

        [DefaultValue(0)]
        public int NoExpiryDate
        {
            get { return this.noExpiryDate; }
            set { ApplyPropertyChange<ListItemCommodityMaster, int>(ref this.noExpiryDate, o => o.NoExpiryDate, value); }
        }

        //[DefaultValue(0)]
        public int ItemGroupID
        {
            get { return this.itemGroupID; }
            set { ApplyPropertyChange<ListItemCommodityMaster, int>(ref this.itemGroupID, o => o.ItemGroupID, value); }
        }

        //[DefaultValue(0)]
        public int ItemClassID
        {
            get { return this.itemClassID; }
            set { ApplyPropertyChange<ListItemCommodityMaster, int>(ref this.itemClassID, o => o.ItemClassID, value); }
        }

        //[DefaultValue(0)]
        public int ItemPM_APMID
        {
            get { return this.itemPM_APMID; }
            set { ApplyPropertyChange<ListItemCommodityMaster, int>(ref this.itemPM_APMID, o => o.ItemPM_APMID, value); }
        }



        [DefaultValue(0)]
        public double Weight
        {
            get { return this.weight; }
            set { ApplyPropertyChange<ListItemCommodityMaster, double>(ref this.weight, o => o.Weight, Math.Round(value, GlobalVariables.Round0)); }
        }

        [DefaultValue(0)]
        public double LeadTime
        {
            get { return this.leadTime; }
            set { ApplyPropertyChange<ListItemCommodityMaster, double>(ref this.leadTime, o => o.LeadTime, value); }
        }

        [DefaultValue(0)]
        public double QuantityAlert
        {
            get { return this.quantityAlert; }
            set { ApplyPropertyChange<ListItemCommodityMaster, double>(ref this.quantityAlert, o => o.QuantityAlert, value); }
        }

        [DefaultValue(0)]
        public double QuantityReorder
        {
            get { return this.quantityReorder; }
            set { ApplyPropertyChange<ListItemCommodityMaster, double>(ref this.quantityReorder, o => o.QuantityReorder, value); }
        }

        [DefaultValue(0)]
        public double CustomsPercent
        {
            get { return this.customsPercent; }
            set { ApplyPropertyChange<ListItemCommodityMaster, double>(ref this.customsPercent, o => o.CustomsPercent, value); }
        }

        [DefaultValue(0)]
        public double ExcisePercent
        {
            get { return this.excisePercent; }
            set { ApplyPropertyChange<ListItemCommodityMaster, double>(ref this.excisePercent, o => o.ExcisePercent, value); }
        }

        [DefaultValue(0)]
        public double VATPercent
        {
            get { return this.vatPercent; }
            set { ApplyPropertyChange<ListItemCommodityMaster, double>(ref this.vatPercent, o => o.VATPercent, value); }
        }


        [DefaultValue(false)]
        public bool InActive
        {
            get { return this.inActive; }
            set { ApplyPropertyChange<ListItemCommodityMaster, bool>(ref this.inActive, o => o.InActive, value); }
        }

        [DefaultValue(false)]
        public bool IsNoExpiryDate
        {
            get { return this.isNoExpiryDate; }
            set { ApplyPropertyChange<ListItemCommodityMaster, bool>(ref this.isNoExpiryDate, o => o.IsNoExpiryDate, value); }
        }

        [DefaultValue(false)]
        public bool IsCustomsPercent
        {
            get { return this.isCustomsPercent; }
            set { ApplyPropertyChange<ListItemCommodityMaster, bool>(ref this.isCustomsPercent, o => o.IsCustomsPercent, value); }
        }

        [DefaultValue(false)]
        public bool IsExcisePercent
        {
            get { return this.isExcisePercent; }
            set { ApplyPropertyChange<ListItemCommodityMaster, bool>(ref this.isExcisePercent, o => o.IsExcisePercent, value); }
        }

        [DefaultValue(false)]
        public bool IsVATPercent
        {
            get { return this.isVATPercent; }
            set { ApplyPropertyChange<ListItemCommodityMaster, bool>(ref this.isVATPercent, o => o.IsVATPercent, value); }
        }

        [DefaultValue(false)]
        public bool IsOrder
        {
            get { return this.isOrder; }
            set { ApplyPropertyChange<ListItemCommodityMaster, bool>(ref this.isOrder, o => o.IsOrder, value); }
        }

        [DefaultValue(false)]
        public bool IsPromotion
        {
            get { return this.isPromotion; }
            set { ApplyPropertyChange<ListItemCommodityMaster, bool>(ref this.isPromotion, o => o.IsPromotion, value); }
        }

        [DefaultValue(false)]
        public bool IsSample
        {
            get { return this.isSample; }
            set { ApplyPropertyChange<ListItemCommodityMaster, bool>(ref this.isSample, o => o.IsSample, value); }
        }

        [DefaultValue(false)]
        public bool IsMerchandising
        {
            get { return this.isMerchandising; }
            set { ApplyPropertyChange<ListItemCommodityMaster, bool>(ref this.isMerchandising, o => o.IsMerchandising, value); }
        }


        #endregion

        protected override System.Collections.Generic.List<ValidationRule> CreateRules()
        {
            List<ValidationRule> validationRules = base.CreateRules();
            validationRules.Add(new SimpleValidationRule("Description", "Reference cannot be blank.", delegate { return this.Description.Length != 0; }));
            validationRules.Add(new SimpleValidationRule("DescriptionOfficial", "Reference cannot be blank.", delegate { return this.DescriptionOfficial.Length != 0; }));
            validationRules.Add(new SimpleValidationRule("ItemCategoryID", "Item Category cannot be empty.", delegate { return this.ItemCategoryID > 0; }));
            validationRules.Add(new SimpleValidationRule("ItemBrandID", "Item Brand cannot be empty.", delegate { return this.ItemBrandID > 0; }));
            validationRules.Add(new SimpleValidationRule("ItemTypeID", "Item Type cannot be empty.", delegate { return this.ItemTypeID > 0; }));
            validationRules.Add(new SimpleValidationRule("ItemClassID", "Item Class cannot be empty.", delegate { return this.ItemClassID > 0; }));
            validationRules.Add(new SimpleValidationRule("ItemGroupID", "Item Group cannot be empty.", delegate { return this.ItemGroupID > 0; }));
            validationRules.Add(new SimpleValidationRule("ItemPM_APMID", "PM & APM cannot be empty.", delegate { return this.ItemPM_APMID > 0; }));
            validationRules.Add(new SimpleValidationRule("SupplierID", "Supplier cannot be empty.", delegate { return this.SupplierID >= 0; }));

            return validationRules;
        }
    }
}
